<HTML>
<HEAD>
<TITLE> Password Generation bookmarklet</TITLE></HEAD>
<BODY>
<script>
function enterKey(inField,e){

    var charCode;

    if(e && e.which)
    {
        charCode = e.which;
    }
    else if (window.event)
    {
        e = window.event;
        charCode = e.keyCode;
    }

    if (charCode == 13) 
    {
        genPass(document.getElementsByTagName('form')[0]) // My Main action
    }
 
}
function genPass(form)
{

    var orig ="javascript:(function(){function e(e){var n=location.href;var r=n.replace(/^.*[./](.*.(com|edu|net|org)).*$/,function(e,t){return t});var i=r.toLowerCase();for(var s=0;s<e.elements.length;s++){var o=e.elements[s];if(o.getAttribute('type')=='password'){var u='XXX'+o.value;if(o.value.length<=2){o.value=t(i,'foo',u)}}}return false}function t(e,t,r){console.log('typed password: '+t);console.log('URL: '+e);console.log('extension Password: '+r);var i=e.concat(r,t);var s='a';var o=CryptoJS.PBKDF2(i,s,{iterations:1}).toString();console.log('hashReturned: '+o);var u=n(o,'0123456789abcdef','00112233445566778899abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.,=-*(){}').substring(0,14);console.log('Generated Password: '+u);return u}function n(e,t,n){console.log(e);console.log(t);console.log(n);var r=t.length;var i=n.length;var s=0;var o=e.length;for(var u=0;u<o;u++){s=s*r+t.indexOf(e.charAt(u))}if(s<0){return 0}var a=s%i;var f=n.charAt(a);var l=Math.floor(s/i);while(l){a=l%i;l=Math.floor(l/i);f=n.charAt(a)+f}return f}function r(e,t){var n=document.createElement('script');n.src=e;n.async=true;n.onreadystatechange=n.onload=function(){var e=n.readyState;if(!t.done&&(!e||/loaded|complete/.test(e))){t.done=true;t()}};document.getElementsByTagName('head')[0].appendChild(n)}r('https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/pbkdf2.js',function(){var t=document.getElementsByTagName('form');for(var n=0;n<t.length;n++){e(t[n])}})})()";
    orig = orig.replace("XXX",form.extensionPassword.value);
    console.log("orig" + orig);
    var front = "<p>Grab our <a id='bookmarklet' href=";
    var back = ">short password web specific</a>";
    var temp = document.getElementById("printHere");
    var temp2 = document.getElementById("log");
    temp.href = orig;
    temp2.innerHTML = orig;
}
</SCRIPT>
<form onkeypress="return enterKey(this,event)">
<p>Extension Password:<input type="textarea" name="extensionPassword" size="50" value = "XXX"></p>
<p><input type="button" value="Get Password" onClick="genPass(this.form)"></p>
</form>
<a id = "printHere">JDPasswordGenerator</a><br>
<textarea id = "log" rows = "30" cols="100"> some stuff</textarea>
</body></html>
</BODY>
</HTML>